create or replace view vac_application_processes_4_1 as
with prc as
(
select
 application_id,
 process_name,
 to_char(process_sequence) process_sequence,
 process_point,
 process_type,
 process_type_code,
 ac_utils.hs(process) process_hs,
 dbms_lob.substr(process,4000, 1)        process_sr1,
 dbms_lob.substr(process,4000, 4000+1 )  process_sr2,
 dbms_lob.substr(process,4000, 8000+1 )  process_sr3,
 dbms_lob.substr(process,4000, 12000+1)  process_sr4,
 attribute_01,
 attribute_02,
 attribute_03,
 attribute_04,
 attribute_05,
 attribute_06,
 attribute_07,
 attribute_08,
 attribute_09,
 attribute_10,
 error_message,
 condition_type,
 condition_expression1,
 condition_expression2,
 build_option,
 authorization_scheme,
 to_char(authorization_scheme_id) authorization_scheme_id,
 component_comment,
 to_char(application_process_id) application_process_id
 from APEX_APPLICATION_PROCESSES
)
select application_id,
       application_process_id,
       authorization_scheme_id,
       process_name,
       to_clob(process_sr1) || to_clob(process_sr2)
    || to_clob(process_sr3) || to_clob(process_sr4)  process_sr,
       U_NAME,
       U_VALUE,
        'APEX_APPLICATION_PROCESSES' src_view_name
from
(
select application_id,
       application_process_id,
       authorization_scheme_id,
       process_name,
       process_sr1,
       process_sr2,
       process_sr3,
       process_sr4,
       U_NAME,
       U_VALUE
 from prc
UNPIVOT INCLUDE NULLS
 ( u_value
   FOR    u_name
   IN
   (
     process_sequence,
     process_point,
     process_type,
     process_type_code,
     process_hs,
     attribute_01,
     attribute_02,
     attribute_03,
     attribute_04,
     attribute_05,
     attribute_06,
     attribute_07,
     attribute_08,
     attribute_09,
     attribute_10,
     error_message,
     condition_type,
     condition_expression1,
     condition_expression2,
     build_option,
     authorization_scheme,
     component_comment
   )
 )
) t;

